package com.itheima.juc18.blockingqueue;

import java.util.concurrent.ArrayBlockingQueue;

/**
 * @author li
 * 生产者
 */
public class Producer extends Thread{
    ArrayBlockingQueue<String> blockingQueue;

    public Producer(ArrayBlockingQueue<String> blockingQueue) {
        this.blockingQueue = blockingQueue;
    }

    @Override
    public void run() {
        while (true) {
            // 不断地把面条放入队列中
            try {
                blockingQueue.put("面条");
                System.out.println(getName() + "厨师放了一碗面条");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
